package com.wxx.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

import java.util.concurrent.Callable;

// mixinStandardHelpOptions 设置为true后 命令行就有帮助手册了
@Command(name = "ASCIIArt", version = "ASCIIArt 1.0", mixinStandardHelpOptions = true)
public class ASCIIArt implements Runnable {

    // 表示命令行通过names中的字符 来接收值(用于解析选项) names中-为简写 --为全称
    @Option(names = { "-s", "--font-size" }, description = "Font size")
    int fontSize = 19;

    // 通过命令后面添加空格分割的参数来复制给数组(用于解析参数)
    @Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli", 
               description = "Words to be translated into ASCII art.")
    private String[] words = { "Hello,", "picocli" }; 

    @Override
    public void run() { 
        // 自己实现业务逻辑  当用户输入命令按下回车后执行的逻辑
        System.out.println("fontSize = " + fontSize);
        System.out.println("words = " + String.join(",", words));
    }

    public static void main(String[] args) {
        int exitCode = new CommandLine(new ASCIIArt()).execute(args); 
        System.exit(exitCode); 
    }
}